package com.zndroid.gridview.load.impl;

import android.content.Context;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.zndroid.gridview.IImageBean;
import com.zndroid.gridview.load.IImageDisplayEngine;
import com.zndroid.gridview.load.ILoadCallBack;
import com.zndroid.gridview.load.Loader;

public final class LocalResIdLoader extends Loader {

    @Override
    public void load(@NonNull Context context, @NonNull ImageView imageView, @NonNull IImageDisplayEngine engine, @NonNull IImageBean bean, @Nullable ILoadCallBack loadCallBack) {
        final int RES_ID_0 = 0;
        final int RES_ID_NOT_FOUND = -1;

        if (RES_ID_0 != bean.supplyResId() && RES_ID_NOT_FOUND != bean.supplyResId()) {
            engine.onDisplayImage(context, imageView, bean.supplyResId(), loadCallBack);
        } else {
            nextLoader.load(context, imageView, engine, bean, loadCallBack);
        }
    }
}
